//
// Created by shubo on 2020/2/6.
//

#pragma once

# include "me_config.h"

struct order_t {
    uint64_t        id;
    uint32_t        type;
    uint32_t        side;
    double          create_time;
    double          update_time;
    uint32_t        user_id;
    char            *market;
    char            *source;
    mpd_t           *price;
    mpd_t           *amount;
    mpd_t           *taker_fee;
    mpd_t           *maker_fee;
    mpd_t           *left;
    mpd_t           *freeze;
    mpd_t           *deal_stock;
    mpd_t           *deal_money;
    mpd_t           *deal_fee;

    static order_t* create(uint64_t id,
                           uint32_t type,
                           uint32_t side,
                           const char *market,
                           const char *source,
                           uint32_t user_id,
                           mpd_t  *amount,
                           mpd_t  *price,
                           mpd_t  *taker_fee,
                           mpd_t  *maker_fee);

    void release();
};

json_t *get_order_info(order_t *order);

int order_match_compare(const void *value1, const void *value2);

int order_id_compare(const void *value1, const void *value2);
